package com.itheima.thread.blockingqueue.demo02;

import java.util.concurrent.ArrayBlockingQueue;

public class CustomerThread implements Runnable {

    private ArrayBlockingQueue<Box> arrayBlockingQueue;
    public CustomerThread(ArrayBlockingQueue<Box> arrayBlockingQueue) {
        this.arrayBlockingQueue = arrayBlockingQueue;
    }

    @Override
    public void run() {
        while (true) {
            Box box = null;
            try {
                box = arrayBlockingQueue.take();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(box.getMilkType() + "," + box.getAmount());
        }
    }
}
